<template>
  <div class="mw-column-center-style" style="width:1.72rem;margin-bottom: 0.1rem;border-radius: 0.04rem;">
    <img style="object-fit:cover;height:1.72rem;width:1.72rem;border-radius: 0.04rem 0.04rem 0 0;" :src="sale.image"></img>
    <div class="mw-column-center-style mw-main-background-white" style="padding:0.1rem;border-radius: 0 0 0.04rem 0.04rem">
      <div class="mw-n-line" style="font-size: 0.13rem;line-height: 0.18rem;width: 1.52rem;height:0.36rem;margin-bottom: 0.08rem">{{sale.title}}</div>
      <div class="mw-row-spacebetween-style" style="width:1.52rem;align-items: center;font-size: 0.11rem;">
        <div class="mw-column-style" style="height:100%;justify-content: space-around">
          <div class="mw-row-style" style="align-items: center">
            <div class="mw-row-style mw-main-red" style="font-weight: bold;align-items: baseline">
              <div style="font-size: 0.1rem">￥</div>
              <div style="font-size: 0.16rem">{{sale.price}}</div>
            </div>
            <div v-if="sale.coupon_amount != 0" class="mw-column-center-style" style="margin-left:0.04rem;justify-content:center;font-size:0.1rem;color:#ffffff;padding:0 0.06rem;height:0.14rem;background-image: url(/static/coupon_icon.png);background-repeat:no-repeat; background-size:100% 100%;-moz-background-size:100% 100%;}
">{{sale.coupon_amount}}元券
            </div>
          </div>
          <div class="mw-row-style mw-third-text-color" style="font-size: 0.11rem">
            <div style="margin-right:0.04rem">{{sale.platform}}</div>
            <div style="text-decoration:line-through">￥{{sale.original_price}}</div>
          </div>
        </div>
        <div @click.stop="sendClickBuy(sale)" class="mw-active-rectangle-button" style="height:0.24rem;line-height: 0.24rem;font-size: 0.11rem">
          去抢购
        </div>
      </div>
    </div>
  </div>

</template>
<script>
  import utils from '../utils'
  import httputil from '../httputil'
  export default {
    props: ['sale'],
    data() {
      return {

      }
    },
    computed: {},
    methods: {
      sendClickBuy(item){
        var that = this
        item.click_total = item.click_total + 1
        httputil.request("discount/click", {discount_id:item.id}, function (successresult) {
          that.$emit('receiveClickBuy',item)
        }, function (errorresult) {
          that.$emit('receiveClickBuy',item)
        }, "POST", true,"")
      }
    }
  }

</script>
<style scoped>

</style>
